package com.hoopchina.ui.search;


import com.hoopchina.news.R;

import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.widget.Button;
import android.widget.TextView;

/**
 * SearchRecordListButtonItem
 * 搜索历史列表的文字 item
 * 
 * @author Guo Baiyu
 */
public class SearchRecordListTextItem extends TextListItem {
    private TextView mSearchRecordText = null;
    private Button mDeleteItemButton;

    /**
     * 
     * @param context
     * @param attrs
     */
    public SearchRecordListTextItem( Context context, AttributeSet attrs ) {
        super( context, attrs );
        init();
    }

    /**
     * 
     * @param context
     */
    public SearchRecordListTextItem( Context context ) {
        super( context );
        init();
    }

    /**
	 * 
	 */
    private void init() {
        String infServiString = Context.LAYOUT_INFLATER_SERVICE;
        LayoutInflater lInflater;
        lInflater = ( LayoutInflater ) getContext().getSystemService( infServiString );
        lInflater.inflate( R.layout.searchrecordlisttextitem, this, true );

        mSearchRecordText = ( TextView ) findViewById( R.id.textViewSearchRecordListTextItem );
        mDeleteItemButton = ( Button ) findViewById( R.id.buttonSearchRecordListDelete );
    }
    
    
    public void setOnSearchHistoryDeleteItemButtonClickListener(
            SearchHistoryDeleteItemButtonClickListener listener)
    {
        mDeleteItemButton.setOnClickListener( listener );
    }
    /**
     * 
     * @return
     */
    public String getItemText() {
        return mSearchRecordText.getText().toString();
    }

    /**
     * 
     * @param text
     */
    public void setItemText( String text ) {
        mSearchRecordText.setText( text );
    }

    /**
     * 
     * @param gravity
     */
    public void setTextGravity( int gravity ) {
        mSearchRecordText.setGravity( gravity );
    }
    public void setDeletButotnTag( String tag ) {
        mDeleteItemButton.setTag( tag );
    }
    
    public String getDeletButotnTag() {
        return ( String ) mDeleteItemButton.getTag();
    }
}
